package com.example.demo.service.impl;

import com.example.demo.dto.GoodsPageRequest;
import com.example.demo.entity.Goods;
import com.example.demo.repository.GoodsRepository;
import com.example.demo.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * GoodsServiceImpl
 *  菜品 service
 * @author liujin
 * @date 2020/12/18 13:15
 */
@Service
public class GoodsServiceImpl implements GoodsService {

    @Autowired
    private GoodsRepository goodsRepository;

    /**
     * 功能描述: 查看菜单
     * @param: [request]
     * @author: liujin
     * @date: 2020/12/18 13:37
     */
    @Override
    public List<Goods> page(GoodsPageRequest request) {
        PageRequest pageRequest = PageRequest.of(request.getPageNum(), request.getPageSize());
        Page<Goods> goods = goodsRepository.findAll(pageRequest);
        return goods.getContent();
    }
}
